package com.example.demo.tool.archery;

import cn.hutool.json.JSONObject;
import lombok.extern.slf4j.Slf4j;

/**
 * @author jiangjinwu
 * @version 1.0
 * @since 2025/10/24 17:09
 */

@Slf4j

public class ArcheryExecutorSimple {

    public static void main(String[] args) {
        ArcheryQueryService queryService = new ArcheryQueryService();
         QueryContext queryContext =  new QueryContext(ArcheryUrlEnum.JBZ_ARCHERY_URL);
        queryContext.setSelContent("select * from t_agency_relation where  1=1");
        queryContext.setPageIndex(0);
        queryContext.setPageSize(5000);
        queryContext.setCookie("_bid_n=193d790be6a7184a73e539; _ga_YFKNQX5E65=GS1.1.1736917810.15.0.1736917819.0.0.0; _ga=GA1.2.2107992107.1721119513; csrftoken=OYMxVBZKoRZrCqMttTwp9zH3H0HbkaEnnWhJlIg4hFToFCo5zuB3gyY5lfcf0Q9z; sessionid=o94mwyc760c96hkv0otx410qc2bk2d11");
        queryContext.setCsrfToken("OYMxVBZKoRZrCqMttTwp9zH3H0HbkaEnnWhJlIg4hFToFCo5zuB3");
        queryContext.setDynamicCondition("and parent_id = 24190");
        JSONObject result = queryService.execute(queryContext);

        NestResultContainer nestResultContainer = new NestResultContainer(result,"xx","id","parent_id");
        nestResultContainer.process(result);
        while (nestResultContainer.hasNext()){
            queryContext.setDynamicCondition(nestResultContainer.getDynamicCondition());
            result = queryService.execute(queryContext);
            nestResultContainer.process(result);
        }
        logger.info("deepth:{}",nestResultContainer.getDeepth());
        logger.info("getSqlResult:{}",nestResultContainer.getSqlResult());
        logger.info("result:{}",nestResultContainer.getData());
    }
}
